package com.orhon.smartcampus.modules.course.fetcher;

import com.orhon.smartcampus.modules.base.mutation.*;
import com.orhon.smartcampus.modules.course.mutation.AddCoursesMutation;
import com.orhon.smartcampus.modules.course.mutation.DeleteCoursesMutation;
import graphql.schema.idl.RuntimeWiring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CourseFetchersLoader {

    @Autowired
    CoursesFetcher coursesFetcher;

    @Autowired
    CourseFetcher courseFetcher;

    @Autowired
    AddCoursesMutation addCoursesMutation;

    @Autowired
    DeleteCoursesMutation deleteCoursesMutation;

    public void LoadFetchers(RuntimeWiring.Builder builder){


        //users -> data
        builder.type("Query" , t->t.dataFetcher("courses" , coursesFetcher));
        builder.type("Query" , t->t.dataFetcher("course" , courseFetcher));

        builder.type("Mutation" , t->t.dataFetcher("addCourse" , addCoursesMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteCourse" , deleteCoursesMutation));


    }


}
